package ch07;

import java.util.HashSet;
import java.util.Iterator;

public class HashSetMain {
    public static void main(String[] args) {
        int [] arr = {1,2,4,8,16,32,64};
        HashSet<Integer> hashSet = new HashSet<>();
        for (int i:arr) {
            hashSet.add(i);
        }
        System.out.println("size: "+hashSet.size());
        System.out.println(hashSet);
        hashSet.add(16);
        hashSet.add(32);
        hashSet.add(64);// set中是无重复的 无序的
        hashSet.remove(16);
        System.out.println(hashSet.contains(32));
        System.out.println("size: "+hashSet.size());
//        for (Iterator<Integer> iterator = hashSet.iterator(); iterator.hasNext();){
//            System.out.println(iterator.next());
//        }
        for (Integer i:hashSet) {
            System.out.println(i);
        }
    }
}
